<?if(!defined("PROLOG_INCLUDED") || PROLOG_INCLUDED!==true)die();?>
<?ShowError($arResult["ERRORS"])?>
<form method="post" action="" enctype="multipart/form-data">
<table>
<?foreach($arResult['FIELDS'] as $FID => $arField):?>
	<?if(in_array($FID, $arParams['FIELDS'])):?>
		<tr>
			<td valign="top">
				<?$LABEL = isset($arParams['CUSTOM_LABEL_' . $FID]) ? $arParams['CUSTOM_LABEL_' . $FID] : ''?>
				<?if(!empty($LABEL)):?><?=$LABEL?><?=in_array($FID, $arParams['REQUIRED']) ? '<span class="required">*</span>' : ''?>:<?else:?>
					<?=is_numeric($FID) ? $arField['NAME'] : LANG('CATALOG_ELEMENT_ADD_LABEL_' . $FID)?><?=in_array($FID, $arParams['REQUIRED']) ? '<span class="required">*</span>' : ''?>:
				<?endif?>
			</td>
		<?if(!is_numeric($FID)):?>
			<td><?
			switch ($FID) {
				case 'CATALOG_SECTION_ID':
					$value = $_POST[$FID];
					?>
					<select name="CATALOG_SECTION_ID" >
						<?foreach($arResult['SECTIONS_TREE'] as $secID => $secName):?>
							<option value="<?=$secID?>" <?=$value == $secID ? 'selected="selected"' : ''?>><?=$secName?></option>
						<?endforeach?>
					</select>
					<?
					break;
				case 'PREVIEW_TEXT':
				case 'DETAIL_TEXT':
					$value = $_POST[$FID];
					?><textarea name="<?=$FID?>" cols="70" rows="10"><?=$value?></textarea><?
					break;
				case 'PREVIEW_PICTURE':
				case 'DETAIL_PICTURE':
					$value = $_POST['PROPERTY'][$arField['CODE']];
					?><input type="file" name="<?=$FID?>" size="70"/><?
					break;
				case 'NAME':
				default:
					$value = $_POST[$FID];
					?><input type="text" name="<?=$FID?>" size="70" value="<?=$value?>"/><?
					break;
			}
			?></td>
		<?else:?>
			<td><?
			switch ($arField['TYPE']) {
				case 'L':
					$values = $_POST[$FID];
					/*?>
					<select name="PROPERTY[<?=$FID?>]" >
						<?foreach($arResult['SECTIONS_TREE'] as $secID => $secName):?>
							<option value="<?=$secID?>" <?=$value == $secID ? 'selected="selected"' : ''?>><?=$secName?></option>
						<?endforeach?>
					</select><?*/
					break;
				case 'F':
					if ($arField['MULTIPLE'] == "Y") {
						$values = $_POST['PROPERTY'][$arField['CODE']];
						$values = empty($values) ? Array('','','','','') : $values;
						foreach ($values as $value) {
							?><input type="file" name="PROPERTY[<?=$FID?>][]" size="70"/><br /><?
						}
					} else {
						$value = $_POST['PROPERTY'][$arField['CODE']];
						?><input type="file" name="PROPERTY[<?=$FID?>]" size="70"/><?
					}
					break;
				case 'S':
				case 'N':
				default:
					if ($arField['MULTIPLE'] == "Y") {
						$values = $_POST['PROPERTY'][$arField['CODE']];
						$values = empty($values) ? Array('','','','','') : $values;
						if (!is_array($values)) {
							$tmp = $values;
							$values = Array($values,'','','','');
						}
						foreach ($values as $value) {
							?><input type="text" name="PROPERTY[<?=$FID?>][]" size="70" value="<?=$value?>"/><br /><?
						}
					} else {
						$value = $_POST['PROPERTY'][$arField['CODE']];
						?><input type="text" name="PROPERTY[<?=$FID?>]" size="70" value="<?=$value?>"/><?
					}
					break;
			}
			?></td>
		<?endif?>
		</tr>
	<?endif?>
<?endforeach?>
		<tr>
			<td></td>
			<td><input type="submit" name="add_<?=$arParams['BTN_NAME']?>" value="<?=$arParams['ADD_BTN_LABEL']?>"/></td>
		</tr>
</table>
</form>